    //
//  WebDemoViewController.m
//  imathbyfruit
//
//  Created by Gopher on 10-12-26.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "WebDemoViewController.h"


@implementation WebDemoViewController

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/



-(id)init{

	self==[super init];
	if(self !=nil){
	}
	
	return self;

}

- (id)initWithTitle:(NSString *)title withNavigationTitle:(NSString *)navTitle {
	
	if (self=[super init]) {
		// Custom initialization
		//[[self tabBarItem] setImage:[UIImage imageNamed:@"icon_help.png"]];
		
		self.title = title;
		self.navigationItem.title = navTitle;
	}
	
	return self;
}

- (void)loadView {

	UIView *contentView = [[[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame] autorelease];
	
	contentView.autoresizesSubviews = YES;
	self.view = contentView;
	[self.view setBackgroundColor:[UIColor colorWithRed:0.14 green:0.18 blue:0.25 alpha:1.00]];
	

	
	 
	CGRect bounds=[[UIScreen mainScreen]applicationFrame];
	searchBar =[[UISearchBar alloc] initWithFrame:	
				CGRectMake(0.0,0.0,bounds.size.width,48.0)];
	searchBar.delegate=self;
	searchBar.placeholder=@"Google";
	[self.view addSubview:searchBar];
	
	 
	//CGRect bounds=[[UIScreen mainScreen]applicationFrame];
	webView=[[UIWebView alloc]initWithFrame:
			 CGRectMake(0.0,48.0, bounds.size.width, bounds.size.height - 48.0)];
	webView.scalesPageToFit = YES;
	NSURL *url=[NSURL URLWithString:@"http://www.google.com"];
	NSURLRequest *requst=[NSURLRequest requestWithURL:url];
	[webView loadRequest:requst];	
	[self.view addSubview:webView];
	[searchBar release];
	[webView release];
	
	
}


/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
	[super loadView];
	CGRect bounds=[[UIScreen mainScreen]applicationFrame];
	searchBar =[[UISearchBar alloc] initWithFrame:	
				CGRectMake(0.0,0.0,bounds.size.width,48.0)];
	searchBar.delegate=self;
	searchBar.placeholder=@"Google";
	[self.view addSubview:searchBar];
	webView=[[UIWebView alloc]initWithFrame:
			 CGRectMake(0.0,48.0, bounds.size.width, bounds.size.height - 48.0)];
	webView.scalesPageToFit = YES;
	NSURL *url=[NSURL URLWithString:@"http://www.google.com"];
	NSURLRequest *requst=[NSURLRequest requestWithURL:url];
	[webView loadRequest:requst];	
	[self.view addSubview:webView];
}
*/

-(void)searchBarSearchButtonClicked:(UISearchBar *)activeSearchBar{

	NSString *query=[searchBar.text stringByReplacingOccurrencesOfString:@"  " withString:@"++"];
	NSURL *url=[NSURL URLWithString:[NSString stringWithFormat: @"http:www.google.com/search?q=%@",query]];
	NSURLRequest *requst=[NSURLRequest requestWithURL:url];
	[webView loadRequest:requst];
}


/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[searchBar release];
	[webView release];
	
    [super dealloc];
}


@end
